package com.base.thread;

/**
 * 创建一个简单线程
 *
 * @author innocent
 * @date 2019/1/17 16:19
 */
public class MyThread extends Thread {

    private int i;

    public MyThread() {

    }

    public MyThread(String name) {
        this.setName(name);
    }

    @Override
    public void run() {
        System.out.println("--------------");
        while (i < 1000) {
            i++;
            System.out.println(Thread.currentThread().getName() +"\t" + i);
        }
    }

    /**
     * 注意： Junit 不能用户多线程测试
     *
     * @author ABC
     * @time 2019/1/18 9:35
     */
    public static void main(String arg[]) {

        MyThread t1 = new MyThread();
        t1.setName("线程1");
        MyThread t2 = new MyThread();
        t2.setName("线程2");
        MyThread t3 = new MyThread("线程3");

        t1.start();
        t2.start();
        t3.start();
    }
}
